-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature spline regularization #1222
Conversation
Initial commit with spline regularization. The implementation of the gradient wrt theta is not completed (swapping to develop for some debugging of censored). Additionally, small fixes of censored gradient (sigma related, not important usually).
Implemented the complete gradient, including the regularization term for the ds_dtheta
FIxed the parameter plot issue (will be in a separate PR). Added the linear regularization to the spline visualization.
Changes that I might have to revert for the Pull request. The ensemble one might've already been pushed by Polina. The solver one completely circumvents dsdtheta gradient calculation due to some "array cannot be inf or NaN" error which pops sometimes, but it's mostly always 0 so removing it makes it easier to deal with for now. This is a big TODO, do not forget.
Fixed the par_sim_idx in the spline solver calculate gradient function. For all conditions, the rdata form is not managed by par_sim_idx, but with par_edata_indices. This is done such that if some parameters are not used in the condition (observable or noise parameters for instance) then the sensitivities wrt. them don't have to be calculated
Added the passing of the edata indices from the calculator to the solver gradient calculation. Additionally, fixed the inner calculator collector quantitative calculation with nansum instead of a regular one (sometimes it gave only nan values because of this...)
Since I've proven that the ds_dtheta gradient contribution is always 0, we can remove all of the code that was calculating it
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #1222 +/- ##
===========================================
- Coverage 88.16% 83.81% -4.36%
===========================================
Files 79 148 +69
Lines 5257 11948 +6691
===========================================
+ Hits 4635 10014 +5379
- Misses 622 1934 +1312 ☔ View full report in Codecov by Sentry. |
- Updated the notebook for non-linear semi-quantitative data - fixed the max_sensi_order problem - changed default min_diff_factor - fix quality
Tests done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sufficiently familiar with the method, therefore just some general comments.
- Please add return type annotations where missing.
- https://pypesto--1222.org.readthedocs.build/en/1222/example/example_nonlinear_monotone.html
- The
visualize_optimized_model_fit
figure is hardly readable - Not sure whether there is a pypesto policy no notebooks, but I'd prefer clearing outputs before merging.
- The
General suggestion: There seems to be some files (in the hierarchical folder) which have below 80% test coverage, perhaps you can improve this with meaningful tests. If not also fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add CODEOWNERS entry for doc/example/example_nonlinear_monotone.ipynb
only looked at pypesto/petab/importer.py
Added tests for untested lines in calculators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are merge conflicts that need to be resolved. Otherwise approving since there are already extensive reviews. Thanks 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider adding a test for the pypesto/visualize/spline_approximation.py? Can be in a later PR to merge this soon.
Yes, that would be good to have. I'll add tests in another PR. |
The main focus of the PR: add spline regularization into the spline approximation method.
Other changed stuff:
parameter_ids_ensemble
list was not a list, so was failing at the.index
call.calculate_quantitative_result
function of theinner_calculator_collector
. It was giving allnan
values, because the summation in the gradient calculation was not anp.nansum
. That's fixed now.inner_calculator_collector
andspline_approximation.solver
gradient calculation. Previously, it was usingpar_sim_idx
as the index forrdata
. However, it can happen that for some conditions not all parameters are used (i.e. observable parameters). In that case,edatas
has aplist
of indices of parameters used for that condition, which has to be used as indices for therdata
object.importer
'screate_objective
function, if there are non-quantitative data types, themax_sensi_order
should be set to 1, as higher-order derivatives are not implemented.parameters.py
related to hierarchical parameter plotting.Note: Still have TODO tests of the regularization.